# Contributor: amolinae06 <amolinaegames@gmail.com>
maintainer="amolinae06 <amolinaegames@gmail.com>"
pkgname=throttled
pkgver=0.10.0
pkgrel=0
pkgdesc="Workaround for Intel throttling issues in Linux."
url="https://github.com/erpalma/throttled"
arch="noarch"
license="MIT"
depends="py3-dbus py3-psutil py3-gobject3 pciutils"
checkdepends="python3"
subpackages="$pkgname-openrc $pkgname-pyc"
options="!check" # no tests.
source="
	https://github.com/erpalma/throttled/archive/v$pkgver/throttled-$pkgver.tar.gz
	no-venv-openrc.patch
	"

prepare() {
	default_prepare
	mv $srcdir/$pkgname-$pkgver/openrc/throttled $srcdir/$pkgname-$pkgver/openrc/throttled.initd
}

pyc() {
	default_pyc
	amove /usr/lib/$pkgname/__pycache__/
}

build() {
	python -m compileall ./*.py
}

package() {
	install -Dm644 etc/throttled.conf "$pkgdir"/etc/throttled.conf
	install -Dm644 openrc/throttled.initd "$pkgdir"/etc/init.d/throttled
	install -Dm755 throttled.py "$pkgdir"/usr/lib/$pkgname/throttled.py
	install -Dm755 mmio.py "$pkgdir"/usr/lib/$pkgname/mmio.py
	cp -a __pycache__ "$pkgdir"/usr/lib/$pkgname/
	install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
sha512sums="
b89c467295bfc592d7b3ce0c4a41fedf436acf8067f8ef63d8596b92343ed8e04d371d065a9e35fdddba40772f12255c30960c2c46f0cbd5093bfc5e72fb4e18  throttled-0.10.0.tar.gz
d68d1b377068f695cfb1f867b6a568c6d98e25ae723076107c65f0c08b78b489c0178066836a3b0c3edda3e7651d998e45abd7be1fcf6da994f8c08916b90321  no-venv-openrc.patch
"
